/*
 * DKGG2012Group22iMatView.java
 */

package dkgg2012group22imat.view;

import dkgg2012group22imat.controller.iMatViewController;
import dkgg2012group22imat.controller.iMatViewController.MainView;
import dkgg2012group22imat.view.entrance.EntrancePanel;
import java.awt.CardLayout;
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.OverlayLayout;

/**
 * The application's main frame.
 */
public class DKGG2012Group22iMatView extends FrameView {
    
    private iMatViewController controller;

    public DKGG2012Group22iMatView(SingleFrameApplication app) {
        super(app);

        controller = new iMatViewController(this);
        
        //initComponents();
        //animationPanel.setLayout(new OverlayLayout(animationPanel));
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = DKGG2012Group22iMatApp.getApplication().getMainFrame();
            aboutBox = new DKGG2012Group22iMatAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        DKGG2012Group22iMatApp.getApplication().show(aboutBox);
    }
    
    public void setView(MainView viewEnum) {
        switch(viewEnum) {
            case ENTRANCE:
                ((CardLayout)mainContentPanel.getLayout()).show(mainContentPanel,"ENTRANCE");
                entrancePanel1.update();
                break;
            case SHOP:
                ((CardLayout)mainContentPanel.getLayout()).show(mainContentPanel,"SHOP");
                break;
            case CHECKOUT:
                ((CardLayout)mainContentPanel.getLayout()).show(mainContentPanel,"CHECKOUT");
                if(checkoutPanel1.getLayoutCard().equals("thirdView")){
                    ((CardLayout)checkoutPanel1.getLayout()).first(checkoutPanel1);
                }else if(checkoutPanel1.getLayoutCard().equals("secondView")){
                    checkoutPanel1.goTo2ndView();
                }
                break;
            default:
                setView(MainView.ENTRANCE);
        }
        
    }
    
    public iMatViewController getController() {
        return controller;
    }

    public JPanel getAnimationPanel() {
        return animationPanel;
    }
    
    public void init() {
        initComponents();
        
        jLayeredPane1.setLayout(new OverlayLayout(jLayeredPane1));
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLayeredPane1 = new javax.swing.JLayeredPane();
        animationPanel = new javax.swing.JPanel();
        mainPanel = new javax.swing.JPanel();
        cartPanel1 = new dkgg2012group22imat.view.CartPanel();
        jPanel1 = new javax.swing.JPanel();
        mainButtonPanel1 = new dkgg2012group22imat.view.MainButtonPanel();
        mainContentPanel = new javax.swing.JPanel();
        entrancePanel1 = new dkgg2012group22imat.view.entrance.EntrancePanel();
        shopPanel1 = new dkgg2012group22imat.view.shop.ShopPanel();
        checkoutPanel1 = new dkgg2012group22imat.view.checkout.CheckoutPanel();

        jLayeredPane1.setName("jLayeredPane1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(dkgg2012group22imat.view.DKGG2012Group22iMatApp.class).getContext().getResourceMap(DKGG2012Group22iMatView.class);
        animationPanel.setBackground(resourceMap.getColor("animationPanel.background")); // NOI18N
        animationPanel.setName("animationPanel"); // NOI18N
        animationPanel.setOpaque(false);
        animationPanel.setLayout(null);
        animationPanel.setBounds(0, 0, 810, 700);
        jLayeredPane1.add(animationPanel, javax.swing.JLayeredPane.DRAG_LAYER);

        mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
        mainPanel.setName("mainPanel"); // NOI18N
        mainPanel.setLayout(new java.awt.BorderLayout());

        cartPanel1.setName("cartPanel1"); // NOI18N
        mainPanel.add(cartPanel1, java.awt.BorderLayout.EAST);

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setOpaque(false);
        jPanel1.setLayout(new java.awt.BorderLayout());

        mainButtonPanel1.setMaximumSize(new java.awt.Dimension(32767, 114));
        mainButtonPanel1.setMinimumSize(new java.awt.Dimension(620, 114));
        mainButtonPanel1.setName("mainButtonPanel1"); // NOI18N
        mainButtonPanel1.setOpaque(false);
        mainButtonPanel1.setPreferredSize(new java.awt.Dimension(0, 114));
        jPanel1.add(mainButtonPanel1, java.awt.BorderLayout.NORTH);

        mainContentPanel.setBackground(resourceMap.getColor("mainContentPanel.background")); // NOI18N
        mainContentPanel.setName("mainContentPanel"); // NOI18N
        mainContentPanel.setOpaque(false);
        mainContentPanel.setLayout(new java.awt.CardLayout());

        entrancePanel1.setBackground(resourceMap.getColor("entrancePanel1.background")); // NOI18N
        entrancePanel1.setName("entrancePanel1"); // NOI18N
        entrancePanel1.setOpaque(false);
        mainContentPanel.add(entrancePanel1, "ENTRANCE");

        shopPanel1.setBackground(resourceMap.getColor("shopPanel1.background")); // NOI18N
        shopPanel1.setName("shopPanel1"); // NOI18N
        mainContentPanel.add(shopPanel1, "SHOP");

        checkoutPanel1.setBackground(resourceMap.getColor("checkoutPanel1.background")); // NOI18N
        checkoutPanel1.setName("checkoutPanel1"); // NOI18N
        checkoutPanel1.setOpaque(false);
        mainContentPanel.add(checkoutPanel1, "CHECKOUT");

        jPanel1.add(mainContentPanel, java.awt.BorderLayout.CENTER);

        mainPanel.add(jPanel1, java.awt.BorderLayout.CENTER);

        mainPanel.setBounds(0, 0, 1281, 887);
        jLayeredPane1.add(mainPanel, javax.swing.JLayeredPane.DEFAULT_LAYER);

        setComponent(jLayeredPane1);
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel animationPanel;
    private dkgg2012group22imat.view.CartPanel cartPanel1;
    private dkgg2012group22imat.view.checkout.CheckoutPanel checkoutPanel1;
    private dkgg2012group22imat.view.entrance.EntrancePanel entrancePanel1;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JPanel jPanel1;
    private dkgg2012group22imat.view.MainButtonPanel mainButtonPanel1;
    private javax.swing.JPanel mainContentPanel;
    private javax.swing.JPanel mainPanel;
    private dkgg2012group22imat.view.shop.ShopPanel shopPanel1;
    // End of variables declaration//GEN-END:variables


    private JDialog aboutBox;
}
